package com.appspot.javametronome.client.view.widget;

public class ButtonGroup {
    
    private GroupableButton[] buttons;

    public ButtonGroup(GroupableButton... buttons) {
        this.buttons = buttons;
        for (GroupableButton button : this.buttons) {
            button.setButtonGroup(this);
        }
    }
    
    public void selectButton(GroupableButton buttonToSelect) {
        for (GroupableButton button : buttons) {
            if (!button.equals(buttonToSelect)) {
                button.setUnselected();
            }
        }
        if (buttonToSelect != null) {
            buttonToSelect.setSelected();
        }
    }
}
